package Demo;

import java.util.Scanner;

public class Task_1 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
  /*      //二维数组的初始化
        //静态初始化
        int [] [] arr=new int [] []{{1,2,4,},{4,5,},{54,8,7}};
        //动态初始化
        //动态初始化1
        String [] [] arr1=new String[3][4];
        //动态初始化2
        String [] [] arr2=new String[1][];
        //错误的情况
        //String [] []  arr3=new String[][0];
        // String[4] [3] arr4=new String [] [];
        // int [] [] arr5=new int [4] [3]{{1,2,4},{1,4},{4,7,8}};
        // 正确
        int []  arr6[] =new int [] [] {{1,2,3},{4,5},{4,7,7}};
        int [] arr8 []={{1,2,3},{4,5},{4,78,8}};*/
        //杨辉三角
        //1.声明并初始化二维数组
        int [] [] yangHui=new int[10][];
        //2.给数组的元素赋值
        for (int i = 0; i < yangHui.length; i++) {
        yangHui[i]=new int[i+1];
        yangHui[i][0]=yangHui[i][i]=1;
            if (i >1) {
                for (int j=1;j<yangHui[i].length-1;j++){
                   yangHui[i][j]=yangHui[i-1][j-1]+yangHui[i-1][j];
                }
            }
        }

        //3.遍历数组
        for (int i = 0; i < yangHui.length; i++) {
            for (int j=0;j<yangHui[i].length;j++){
                System.out.print(yangHui[i][j]+" ");
            }
            System.out.println();
        }

    }
}
